package com.qiu.wbpostman.action;

import java.util.Date;
import java.util.Map;

import weibo4j.User;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.qiu.wbpostman.entity.UserMail;
import com.qiu.wbpostman.service.WbService;

public class WelcomeAction implements Action{

	private UserMail userMail;
	public String execute() throws Exception {
		// 设置userMail信息
		// 从session中取出user
		ActionContext context = ActionContext.getContext();
		Map<?, ?> session = context.getSession();
		User user = (User) session.get("user");
		if(user != null) {
			userMail.setId(Long.parseLong(user.getId()+""));
			userMail.setUserName(user.getName());
		}
		userMail.setCreateDate(new Date());
		WbService wbService = new WbService();
		wbService.saveUserMail(userMail);
		return SUCCESS;
	}
	public UserMail getUserMail() {
		return userMail;
	}
	public void setUserMail(UserMail userMail) {
		this.userMail = userMail;
	}

}
